#include "PUCCH_TestCase_gen.h"
#if UL_MEX_FLAG
#include "mex.h"
#endif
void PUCCH_TestCase_Param_gen
(
	INOUT stULParamTable *SimParam,
	IN  int8 FormatFlag,
	IN  int8  PUCCH_Case_Mode,
    IN  int Caseidx
)
{
	if (PUCCH_Case_Mode == 0)
	{
        #define  CASENum  20

		int PUCCH_UCI_BRP[10][4] = { {1,1,1,1},{1,0,0,0},{0,1,0,0},{1,1,0,0},{0,0,1,1},{0,0,0,0},{0,1,0,0},{1,0,0,1},{1,1,0,0} };

		 if (FormatFlag == 0)
		{			
			int8 SymNum[CASENum] =      { 	8,	7,	8,	9,	10,	11,	12,	14, 12,14};
			int8 SymStartPos[CASENum] = { 	6,	5,	4,	1,	0,	0,	1,	0,  0, 0};
			int RBStartPos[CASENum][2] = { {0,100},	{12,100}, {22,100}, {32,100}, {42,100},{52,100}, {62,100}, {72,100}, {82,100}, {92,100} };
			int8	HopMod[CASENum] = { 0,	0, 0,1,	1,	1,	1,	2,	2,	2 };
			int n_ID[CASENum] = { 10,100,200,300,400,500,600,700,800,900 };
			int8 intra_slot_hopping[CASENum] = { 0,	0, 0,0,	0,	1,	1,	1,	1,	1 };
			int8 F1_OCC_Index[CASENum]     = { 0,	0,	1,	0,	1,	0,	1,	0,	1,	0 };
			int8 slotIdx[CASENum] = { 0,1,2,3,4,5,6,7,8,9 };
			int8 bitlen_Table[CASENum] = { 1,2,1,2,1,2,1,2 ,1,2,1,2 };

			SimParam->m0 = Caseidx;
			SimParam->n_ID = n_ID[Caseidx];
			SimParam->N_PUCCH_SYM = SymNum[Caseidx];
			SimParam->HopMod = HopMod[Caseidx];
			SimParam->PUCCH_RB_Index[0] = RBStartPos[Caseidx][0];
			SimParam->PUCCH_RB_Index[1] = RBStartPos[Caseidx][1];
			SimParam->FirstSym_Pos = SymStartPos[Caseidx];
			SimParam->SR_Length = 0;
			SimParam->SlotIdx = Caseidx;
            SimParam->intra_slot_hopping = intra_slot_hopping[Caseidx];
            SimParam->F1_OCC_Index = F1_OCC_Index[Caseidx];

			SimParam->SR_Length = 0;
			SimParam->ACK_Length = bitlen_Table[Caseidx % 8];
			                

			SimParam->PUCCH_BitLen = SimParam->SR_Length + SimParam->ACK_Length + SimParam->CSIP1_Length;
			if (SimParam->ACK_Length > 0)
			{
				for (int i = 0; i < SimParam->PUCCH_BitLen; i++)
				{
					SimParam->Fmt01_UCI_BRP[i] = PUCCH_UCI_BRP[Caseidx][i];
				}
			}
			else
			{
				SimParam->SR_Length = 1;
				SimParam->Fmt01_UCI_BRP[0] = PUCCH_UCI_BRP[Caseidx][0];
				SimParam->SR_Value = SimParam->Fmt01_UCI_BRP[0];
			}
			SimParam->PUCCH_RB_Num = 1;

		}

		else if (FormatFlag == 1)
		{
			 int8 SymNum[CASENum] = { 12,	7,	8,	9,	10,	11,	12,	14, 12,14 };
			 int8 SymStartPos[CASENum] = { 0,	5,	4,	1,	0,	0,	1,	0,  0, 0 };
			 int RBStartPos[CASENum][2] = { {0,100},	{12,100}, {22,100}, {32,100}, {42,100},{52,100}, {62,100}, {72,100}, {82,100}, {92,100} };
			 int8	HopMod[CASENum] = { 0,	0, 0,1,	1,	1,	1,	2,	2,	2 };
			 int n_ID[CASENum] = { 0,100,200,300,400,500,600,700,800,900 };
			 int8 intra_slot_hopping[CASENum] = { 0,	0, 0,0,	0,	1,	1,	1,	1,	1 };			
			 int8 slotIdx[CASENum] = { 0,1,2,3,4,5,6,7,8,9 };
			 int Additional_DMRS[CASENum] = { 0,1, 0,1,	0,	1,	0,	1,	0,	1 };
			 int CellID[CASENum] = {0,5,10,15,20,25,30,35,40,45};
			 int RNTI[CASENum] = {0,10,20,30,40,50,60,70,80,90};

			SimParam->Additional_DMRS = Additional_DMRS[Caseidx];
			SimParam->n_ID = n_ID[Caseidx];
			SimParam->N_PUCCH_SYM = SymNum[Caseidx];
			SimParam->HopMod = HopMod[Caseidx];
			SimParam->PUCCH_RB_Index[0] = RBStartPos[Caseidx][0];
			SimParam->PUCCH_RB_Index[1] = RBStartPos[Caseidx][1];
			SimParam->FirstSym_Pos = SymStartPos[Caseidx];
			SimParam->SlotIdx = slotIdx[Caseidx];
	

			SimParam->CellID = CellID[Caseidx];
			SimParam->HopMod = HopMod[Caseidx];
			SimParam->RNTI = RNTI[Caseidx];
			SimParam->Half_BPSK = 0;
			SimParam->PUCCH_RB_Num = 1;
			SimParam->CSIP1_Length = 4;
			for (int i = 0; i < SimParam->CSIP1_Length; i++)
			{
				SimParam->Fmt01_UCI_BRP[i] = PUCCH_UCI_BRP[Caseidx][i];
			}

			SimParam->CSI1_Value = SimParam->Fmt01_UCI_BRP[0] + 2 * SimParam->Fmt01_UCI_BRP[1] + 4 * SimParam->Fmt01_UCI_BRP[2] + 8 * SimParam->Fmt01_UCI_BRP[3];

		}
	}
	else
	{
		PUCCH_TestCase_gen(SimParam, Caseidx, FormatFlag);
	}	   
}

